/*
Copyright 2007 Julian Asamer

This file is part of Fractalicious.

    Fractalicious is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Fractalicious is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Fractalicious.  If not, see <http://www.gnu.org/licenses/>.
*/

#import <Foundation/Foundation.h>

//++++++++++
//+ STATIC +
//++++++++++
//A few 2D-Vectorbasics + my uniqe Transformeralgorithm. :-)

typedef struct {
	float vx;
	float vy;
} Vector2D;
typedef struct {
	float x;
	float y;
} Point2D;
//"Gerade" is a German word for the english term "staight line". I use the German
//version because the it is shorter & and has only the mathematical meaning.
typedef struct {
	Point2D p;
	Vector2D v;
} Gerade2D;
typedef struct {
	Point2D p;
	Point2D q;
} Line2D;
typedef struct {
	float t1, t2, o1, o2;
} Transformer2D;
@interface Vector : NSObject

//Vector2D related

//Creating
	+ (Vector2D) makeVector;
	+ (Vector2D) makeVectorWithvx: (float) vx vy: (float) vy;
	
//Operations
	+ (Vector2D) addVector: (Vector2D) v toVector: (Vector2D) w;
	+ (Vector2D) reverseVector: (Vector2D) v;
	+ (Vector2D) multiplyVector: (Vector2D) v with: (float) factor;
	+ (Vector2D) divideVector: (Vector2D) v through: (float) divisor;
	+ (float) lengthOfVector: (Vector2D) v;
	+ (Vector2D) unityVectorOfVector: (Vector2D) v;
	+ (Vector2D) turnVectorLeft: (Vector2D) v;
	+ (Vector2D) turnVectorRight: (Vector2D) v;


//Point2D related

//Creating
	+ (Point2D) makePoint;
	+ (Point2D) makePointWithx: (float) x y: (float) y;
	
//Operations
	+ (Vector2D) point: (Point2D) p toPoint: (Point2D) q;
	+ (Point2D) addVector: (Vector2D) v toPoint: (Point2D) p;
	+ (Point2D) subtractVector: (Vector2D) v fromPoint: (Point2D) p;
	+ (BOOL) point: (Point2D) p equalsPoint: (Point2D) q withMaxDistance: (float) d;
	

//Line2D related

//Creating
	+ (Line2D) makeLine;
	+ (Line2D) makeLineWithPoint:(Point2D) p andPoint: (Point2D) q;
	+ (Line2D) makeLineWithPoint:(Point2D) p andVector: (Vector2D) v;
	+ (Line2D) makeLineWithpx: (float)px py: (float)py qx: (float)qx qy: (float)qy;

//Operations
	+ (float) lengthOfLine: (Line2D)l;
	+ (Gerade2D) convertLineToGerade: (Line2D) line;
	
	
//Gerade2D related

//Creating
	+ (Gerade2D) makeGerade;
	+ (Gerade2D) makeGeradeWithPoint: (Point2D) p andVector: (Vector2D) v;
	+ (Gerade2D) makeGeradeWithPoint: (Point2D) p andPoint: (Point2D) q;

//Operations
	+ (Point2D) cutGerade:(Gerade2D) g withGerade:(Gerade2D) h;


//Transformer2D related
	+ (Transformer2D) makeTransformerWithLine: (Line2D) rec1 andLine: (Line2D) rec2;
	+ (Transformer2D) makeTransformerWithp1: (Point2D) p1 q1: (Point2D) q1 
										 p2: (Point2D) p2 q2: (Point2D) p2;

//Operation
	+ (Line2D) transformLine: (Line2D) l withTransformer: (Transformer2D) t;
@end